﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Digitalmes.Model.ProcessManagement;
using Digitalmes.Model;



namespace Digitalmes.ViewModel.ProcessManagement.ProcessParameterVMs
{
    public partial class ProcessParameterOpDetailListVM1 : BasePagedListVM<ProcessParameter, ProcessParameterDetailSearcher1>
    {
        
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("ProcessParameter", GridActionStandardTypesEnum.AddRow, "新建","", dialogWidth: 800),
                this.MakeStandardAction("ProcessParameter", GridActionStandardTypesEnum.RemoveRow, "删除","", dialogWidth: 800),
            };
        }
 
        protected override IEnumerable<IGridColumn<ProcessParameter>> InitGridHeader()
        {
            return new List<GridColumn<ProcessParameter>>{
                
                this.MakeGridHeader(x => x.TagId).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.变量"].Value),
                this.MakeGridHeader(x => x.TagName).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.变量名称"].Value),
                this.MakeGridHeader(x => x.SetValue).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.设定值"].Value),
                this.MakeGridHeader(x => x.Precision).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.精度"].Value),
                this.MakeGridHeader(x => x.ParameterName).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.参数名称"].Value),
                this.MakeGridHeader(x => x.DataType).SetEditType(EditTypeEnum.ComboBox,typeof(TagDataTypeEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.数据类型"].Value),
                this.MakeGridHeader(x => x.Active).SetEditType(EditTypeEnum.ComboBox,Utils.GetBoolCombo(BoolComboTypes.YesNo, selectText:Wtm.Localizer?["Sys.PleaseSelect"])).SetTitle(@Localizer["Page.激活"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<ProcessParameter> GetSearchQuery()
        {
                
            var id = (long?)Searcher.OpId.ConvertValue(typeof(long?));
            if (id == null)
                return new List<ProcessParameter>().AsQueryable().OrderBy(x => x.ID);
            var query = DC.Set<ProcessParameter>()
                .Where(x => id == x.OpId)

                .OrderBy(x => x.ID);
            return query;
        }

    }

    public partial class ProcessParameterDetailSearcher1 : BaseSearcher
    {
        
        [Display(Name = "_Model._ProcessParameter._Op")]
        public string OpId { get; set; }
    }

}

